package MultiThreaded;

import javax.swing.SwingUtilities;

import GUI.View;

public class SimulationController {
	
	
	//method that runs the simulation 
	public static Double runSim(SimulationBean simBean) {		
		
		//start of the time counter
	    long start=System.currentTimeMillis();
	    
	    //creation of another thread for each simulation launched
		CalculusThread ct =new CalculusThread(simBean.getCallPutFlag(), simBean.getS(),simBean.getX(), simBean.getT(),
				simBean.getR(), simBean.getB(), simBean.getV(), simBean.getnSteps(), simBean.getnSimulations(), simBean.getResultat());
		Thread Tct= new Thread(ct);
		Tct.start();
		
		/******* Unquote to have a single calculation and an estimation of time consumption displayed in the console *********/
		/*try {
			Tct.join();
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}*/
		
	    //end of the time counter
	    long end=System.currentTimeMillis();
	    long time=end-start;
	    System.out.println("time=" + time);

		return(ct.getResult());
	}


	public static void main (String [] args) {
		
		SwingUtilities.invokeLater(new Runnable(){

			public void run(){
				View view=new View();
				view.setVisible(true);	
			}
			
	});
			
	}
}

